package com.tnt.hpit.helper;

import java.util.ArrayList;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.InputProcessor;
public class ControllerInputMultiplexer {
	private InputMultiplexer inputMultiplexerTemp, inputMultiplexer;
	private boolean checkSaoLuu = false;
	public ControllerInputMultiplexer(){
		inputMultiplexer = new InputMultiplexer();
		inputMultiplexerTemp = new InputMultiplexer();
		Gdx.input.setInputProcessor(inputMultiplexer);
	}
	public InputMultiplexer getIM(){
		return inputMultiplexer;
	}
	public void setOneInputProcessor(InputProcessor inputProcessor){
		if ( checkSaoLuu == false ){
			inputMultiplexerTemp.clear();
			for ( InputProcessor ip : inputMultiplexer.getProcessors() )
				inputMultiplexerTemp.addProcessor(ip);
			inputMultiplexer.clear();
			inputMultiplexer.addProcessor(inputProcessor);
			checkSaoLuu = true;
		}
	}
	public void resetAllInputProcessor(){
		if ( checkSaoLuu ){
			inputMultiplexer.clear();
			for ( InputProcessor ip : inputMultiplexerTemp.getProcessors() )
				inputMultiplexer.addProcessor(ip);
			checkSaoLuu = false;
		}
	}
}
